﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using LGSVR.Common;
using LGSVR.BLL.Sys;

namespace LGSVR_WEB.program
{
    public partial class messageGroupList : LGSVR.Common.DataBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserID"] == null)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "out", "<script>alert('系统超时或服务器故障，请退出重新登录！');window.parent.parent.navigate('../Logout.aspx');</script>");
            }

            if (!IsPostBack)
            {               
                gvDataBind("");
            }
        }
        private void gvDataBind(string strWhere)
        {
            DataTable dt;
            int totalRS;
            int pageIndex;
            if (!string.IsNullOrEmpty(Request.QueryString["pg"]) && Utils.IsNumber(Request.QueryString["pg"]))
            {
                pageIndex = int.Parse(Request.QueryString["pg"]);
            }
            else
            {
                pageIndex = 1;
            }

            dt = GetList("messageGroup", " grade desc ", strWhere, pageIndex, PageSize, out totalRS);
            rptBody.DataSource = dt;
            rptBody.DataBind();
            SplitHtmlCode = Split.GetHtmlCode("messageGroupList.aspx", 8, pageIndex, PageSize, totalRS);
        }
       
        protected void Delete(object sender, CommandEventArgs e)
        {
 
        }

        protected void Search(object sender, CommandEventArgs e)
        {
            string strWhere = "";
            if (txtGrade.Text.Trim() != "") //级别
            {
                strWhere = " and Grade like '%" + txtGrade.Text.Trim() + "%'";
            }
            if (txtgroupName.Text.Trim() != "")//节目组
            {
                strWhere += " and groupName like '%" + txtgroupName.Text.Trim() + "%'";
            }
            gvDataBind(strWhere);

        }
        protected void lbtnDel_Click(object sender, EventArgs e)
        {
            bool isTrue = Delete("paramList", Request["chkId"]);
            if (isTrue)
            {
                MsgContent = ShowMessage("恭喜您，删除成功！", MessageType.Success, false, true);
                NoRefresh();
            }
            else
            {
                MsgContent = ShowMessage("对不起,操作失败，请重试。", MessageType.Error, false, true);
            }
        }

        protected void lbtnUnable_Click(object sender, EventArgs e)
        {
            bool isTrue = UpdateState("paramList", false, Request["chkId"]);
            if (isTrue)
            {
                MsgContent = ShowMessage("恭喜您，停用成功！", MessageType.Success, false, true);
                NoRefresh();
            }
            else
            {
                MsgContent = ShowMessage("对不起,操作失败，请重试。", MessageType.Error, false, true);
            }
        }
    }
}